package com.wtone.platform.gat.images.gat.controller;

import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.wtone.platform.gat.images.gat.core.BaseController;
import com.wtone.platform.gat.images.gat.core.R;
import com.wtone.platform.gat.images.gat.entity.SubscribeDB;
import com.wtone.platform.gat.images.gat.service.ISubscribeService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @author aiLin
 * @date 2020-09-28
 * @desc:订阅对象 提供者 DB持久化控制层
 */
@Api(tags = "订阅对象 DB", value = "Subscribe api")
@RestController
@ApiSort(8)
@RequestMapping("subscribe")
public class SubscribeController extends BaseController
{

	@Autowired
	private ISubscribeService subscribeService;

	@ApiOperation(value = "根据卡片id查询订阅对象信息" , position = 10)
	@GetMapping("get/{id}")
	public SubscribeDB get(@PathVariable("id") String id){
		return subscribeService.selectSubscribeById(id);
	}

	@ApiOperation(value = "查询订阅对象列表", position = 10)
	@ApiResponses(value = {
			@ApiResponse(code = 200, message="List结果集",response= SubscribeDB.class),
			@ApiResponse(code = 404, message = "not found error")
	})
	@ApiImplicitParam(name = "params", value = "请求参数", required = false, paramType="path", dataType = "MAP")
	@GetMapping("list")
	public R list(SubscribeDB subscribe){
		//startPage();
		return R.data(subscribeService.selectSubscribeList(subscribe));
	}

	@ApiOperation(value = "新增订阅对象", position = 1)
	@PostMapping("save")
	public R addSave(@RequestBody SubscribeDB subscribe){
		return toAjax(subscribeService.insertSubscribe(subscribe));
	}


	@ApiOperation(value = "修改订阅对象", position = 2)
	@PostMapping("update")
	public R editSave(@RequestBody SubscribeDB subscribe){
		return toAjax(subscribeService.updateSubscribe(subscribe));
	}


	@ApiOperation(value = "根据卡片id删除订阅对象", position = 3)
	@PostMapping("remove")
	public R remove(String ids)
	{
		return toAjax(subscribeService.deleteSubscribeByIds(ids));
	}

}
